//接收两个参数 之前的状态preState,和动作对象action
export default function countRedux(preState = [], action) {
  const { type, data } = action
  if (type === 'add') {

    if (data) {
      if (!data.path) return preState

      const isPush = preState.filter(val => val.key === data.key)[0]
      if (!isPush) {
        preState.push(data)
      }

    }
  }

  if (type === 'del') {
    if (data.length) {
      preState = data
    }
  }

  // 根据传进来的type判断要进行的操作
  return preState
}